package com.allqj.sfx.ddd.member.domain.enums;

import com.allqj.sfx.infrastructure.exceptions.BusinessException;

/**
 * @author sjw
 * @className FlowException
 * @date 2022/7/22 13:55
 * @description: 审批流 异常状态码 1051-1100
 */
public enum FlowExceptionEnum {

    FLOW_DEF_NOT_EXIST(1051, "审批流程暂未配置!"),
    FLOW_TASK_DEF_NOT_EXIST(1052, "审批流程任务节点暂未设置!"),
    INSTANCE_NOT_EXIST(1053, "审批流实例不存在!"),
    INSTANCE_END(1054, "审批流实例已结束!"),
    FLOW_APPROVER_NO_RIGHT(1055, "无审批权限!"),
    ;

    //状态码
    private int statusCode;
    //描述信息
    private String message;

    FlowExceptionEnum(int statusCode, String message) {
        this.statusCode = statusCode;
        this.message = message;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public String getMessage() {
        return message;
    }

    public static void throwException(BusinessExceptionEnum status) {
        throw new BusinessException(status.getStatusCode(), status.getMessage());
    }

    public static void throwException(BusinessExceptionEnum status, String message) {
        throw new BusinessException(status.getStatusCode(), message);
    }

    public void throwException() {
        throw new BusinessException(getStatusCode(), getMessage());
    }

}
